package leetbook.math;

public class Solution190 {



    public static void main(String[] args) {
        int b = -3;
        System.out.println(reverseBits(b));
    }

    // you need treat n as an unsigned value
    public static int reverseBits(int n) {
        int res = 0; //c用来记录移动了多少次
        for (int i = 0; i < 32; i++) {
            res |= (n&1)<<(31-i); //把n的第i位放到res的第31-i位
            n>>>=1; //n无符号右移
        }
        return res;
    }
}
